<!-- 右侧头部通用 -->
<template>
  <div class="header">
    <el-breadcrumb separator="/" class="header-left">
      <el-breadcrumb-item :to="{ path: '/home' }">首页</el-breadcrumb-item>
      <el-breadcrumb-item v-for="item in $route.meta" :key="item">{{
        item
      }}</el-breadcrumb-item>
    </el-breadcrumb>
    <el-dropdown class="header-right" @command="handleCommand">
      <span class="el-dropdown-link">
        <img
          src="https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1602564440115&di=6db4c0ac648109a92d663424d4aca799&imgtype=0&src=http%3A%2F%2Fpic5.997788.com%2Fpic_search%2F00%2F20%2F20%2F53%2Fse20205362.jpg"
          alt=""
        />
      </span>
      <el-dropdown-menu slot="dropdown">
        <el-dropdown-item command="home">首页</el-dropdown-item>
        <el-dropdown-item command="logout">退出</el-dropdown-item>
      </el-dropdown-menu>
    </el-dropdown>
  </div>
</template>

<script>
import myaxios from "@/axios/myaxios";
export default {
  data() {
    //这里存放数据
    return {};
  },
  //监听属性 类似于data概念
  computed: {},
  //监控data中的数据变化
  watch: {},
  //方法集合
  methods: {
    handleCommand(command) {
      if (command == "home") {
        this.$router.push("/home");
      } else {
        myaxios.get("/admin/signout").then((res) => {
          this.$message({
            type: "success",
            message: "退出系统",
          });
          this.$router.push("/");
        });
      }
    },
  },
  //生命周期 - 创建完成（可以访问当前this实例）
  created() {},
  //生命周期 - 挂载完成（可以访问DOM元素）
  mounted() {},
  beforeCreate() {}, //生命周期 - 创建之前
  beforeMount() {}, //生命周期 - 挂载之前
  beforeUpdate() {}, //生命周期 - 更新之前
  updated() {}, //生命周期 - 更新之后
  beforeDestroy() {}, //生命周期 - 销毁之前
  destroyed() {}, //生命周期 - 销毁完成
  activated() {}, //如果页面有keep-alive缓存功能，这个函数会触发
};
</script>
<style  lang='less'>
.header {
  height: 60px;
  line-height: 60px;
  display: flex;
  justify-content: space-between;
  padding: 0 15px;
  background: #eff2f7;
  .header-left {
    height: 60px;
    line-height: 60px;

    el-breadcrumb-item {
    }
  }

  .header-right {
    margin-top: 12px;
    .el-dropdown-link {
      img {
        width: 36px;
        height: 36px;
        border-radius: 50%;
      }
    }

    el-dropdown-menu {
      el-dropdown-item {
      }
    }
  }
}
</style>